package com.ysd.ziyuanshiyongtongji.dao;


import com.ysd.ziyuanshiyongtongji.model.Statistics;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

/**
 * IStatisticsDao
 */
public interface IStatisticsDao extends JpaRepository<Statistics,Integer>{
    @Query(value = "insert into statistics(read_room_id,day,num) select read_room_id,DATE_SUB(curdate(),INTERVAL 1 DAY),count(id) num from consume_log where TO_DAYS(now())-TO_DAYS(in_time)<=1 GROUP BY read_room_id,DATE_SUB(curdate(),INTERVAL 1 DAY)",nativeQuery = true)
    void autoStatistics();
}